let targets = try!(generate_targets(to_build, mode, filter, release));
let target_with_args = match *target_rustc_args {
- Some(args) => {
- if targets.len() > 1 {
- return Err(human("extra arguments to `rustc` can only be \
- invoked for one target"))
- }
+ Some(args) if targets.len() == 1 => {
let (target, profile) = targets[0];
let mut profile = profile.clone();
profile.rustc_args = Some(args.to_vec());
Some((target, profile))
- },
+ }
+ Some(_) =>
+ return Err(human("extra arguments to `rustc` can only be passed to one target, \
+ consider filtering\nthe package by passing e.g. `--lib` or \
+ `--bin NAME` to specify a single target")),
None => None,
};
fn setup() {
}
+fn cargo_rustc_error() -> &'static str {
+ "extra arguments to `rustc` can only be passed to one target, consider filtering\n\
+ the package by passing e.g. `--lib` or `--bin NAME` to specify a single target"
+}
+
test!(build_lib_for_foo {
let p = project("foo")
.file("Cargo.toml", r#"
.arg("--").arg("-Z").arg("unstable-options"),
execs()
.with_status(101)
- .with_stderr("extra arguments to `rustc` can only be invoked for one target"));
+ .with_stderr(cargo_rustc_error()));
});
test!(build_with_args_to_one_of_multiple_binaries {
.arg("--").arg("-Z").arg("unstable-options"),
execs()
.with_status(101)
- .with_stderr("extra arguments to `rustc` can only be invoked for one target"));
+ .with_stderr(cargo_rustc_error()));
});
test!(build_with_args_to_one_of_multiple_tests {